package com.yzt.p_base;

import android.app.Application;
import android.content.Context;

import com.yzt.p_base.utils.LogDataUtils;

/**
 * author : bob
 * date   : 2022/11/29
 * desc   :
 */
public class AppUtils {

    private static Application sApplication = null;

    /**
     * 初始化，注入application context
     */
    public static void init(Application application) {
        sApplication = application;
        LogDataUtils.init();
    }

    public static Application getApp() {
        checkApplication();
        return sApplication;
    }

    public static Context getContext() {
        checkApplication();
        return sApplication.getApplicationContext();
    }

    private static void checkApplication() {
        if (sApplication == null) {
            throw new IllegalStateException("should init first !");
        }
    }
}
